<?php $this->load->view('layout/header');?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="page-title">评价管理<small> 商品评价管理</small></h3>
            <?php echo breadcrumb(array('评价管理', '商品评价管理')); ?>
        </div>
    </div>
    <?php echo execute_alert_message() ?>
    <div class="row-fluid">
        <div class="span12">
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-search"></i>搜索</div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;"></a>
                        <a class="remove" href="javascript:;"></a>
                    </div>
                </div>
                <div class="portlet-body form">
                    <form class="form-horizontal form-search" action="<?php echo base_url('tourismreviews/grid') ?>" method="get">
                        <div class="row-fluid">
                            <div class="span5">
                                <div class="control-group">
                                    <label class="control-label">订单ID</label>
                                    <div class="controls">
                                        <input type="text" name="order_id" value="<?php echo $this->input->get('order_id') ?>" class="m-wrap medium" placeholder="订单编号">
                                    </div>
                                </div>
                            </div>
                            <div class="span5">
                                <div class="control-group">
                                    <label class="control-label">商品名称</label>
                                    <div class="controls">
                                        <input type="text" class="m-wrap medium" name="goods_name" value="<?php echo $this->input->get('goods_name') ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row-fluid">
                            <div class="span5">
                                <div class="control-group">
                                    <label class="control-label">用户名称</label>
                                    <div class="controls">
                                        <input type="text" class="m-wrap medium" name="user_name" value="<?php echo $this->input->get('user_name') ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="span5">
                                <div class="control-group">
                                    <label class="control-label">评价状态</label>
                                    <div class="controls">
                                        <select class="medium m-wrap" name="status">
                                            <option value="">请选择...</option>
                                            <?php foreach (array(1=>'待审核', 2=>'通过', 3=>'未通过') as $key=>$value) :?>
                                                <option value="<?php echo $key ?>" <?php if ($key == $this->input->get('status')): ?>selected="selected"<?php endif?>><?php echo $value ?></option>
                                            <?php endforeach;?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-actions">
                            <button class="btn green" type="submit">搜索</button>
                            <button class="btn reset_button_search" type="button">重置条件</button>
                        </div>
                    </form>
                </div>
            </div>
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>列表</div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;"></a>
                        <a class="remove" href="javascript:;"></a>
                    </div>
                </div>
                <div class="portlet-body flip-scroll">
                    <div class="dataTables_wrapper form-inline">
                        <div class="row-fluid scebery-order-pagination">
                            <span class="dataTables_info">
                                <span>当前第</span><span style="color: red"><?php echo $pg_now;?></span>页 
                                <span>共</span><span style="color: red"><?php echo $all_rows;?></span>条数据
                                <span>每页显示20条 </span>
                                <?php echo $pg_list; ?>
                            </span>
                            <span class="scebery-order-find">
                                <input type="text" name="pg" value="<?php echo isset($pg_now) ? $pg_now :'';?>" class="m-wrap small" placeholder="请输入页数">
                                <button type="button" class="btn green">确定</button>
                                <button type="button" class="btn green" onclick="window.location.href=localtion.href">刷新</button>
                                <a type="button" class="btn yellow agree" flag="1" pg="<?php echo isset($pg_now) ? $pg_now :'1';?>">审核通过</a>
                                <a type="button" class="btn yellow reject" flag="2" pg="<?php echo isset($pg_now) ? $pg_now :'1';?>">审核拒绝</a>
                            </span>
                        </div>
                        <?php if ($all_rows > 0) :?>
                        <table class="table table-striped table-bordered table-hover" id="sample_1">
                            <thead class="flip-content">
                                <tr>
                                    <th width="30"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/></th>
                                    <th width="40">编号</th>
                                    <th>订单ID</th>
                                    <th>订单产品ID</th>
                                    <th>商品ID</th>
                                    <th>商品名称</th>
                                    <th>用户名称</th>
                                    <th>评分星级</th>
                                    <th>评价内容</th>
                                    <th>评价状态</th>
                                    <th>评价时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($page_list->result() as $item) : ?>
                                <tr>
                                    <td width="30"><input type="checkbox" class="checkboxes order-review" value="<?php echo $item->id;?>"/></td>
                                    <td width="40"><?php echo $item->id;?></td>
                                    <td><?php echo $item->order_id;?></td>
                                    <td><?php echo $item->order_product_id;?></td>
                                    <td><?php echo $item->goods_attr_id;?></td>
                                    <td width="200">
                                        <p><?php echo $item->goods_name;?></p>
                                        <?php echo $item->attribute_value;?>
                                    </td>
                                    <td><?php echo $item->user_name;?></td>
                                    <td><?php echo $item->review_score;?></td>
                                    <td width="200"><?php echo $item->user_content;?></td>
                                    <td width="100">
                                        <p><?php echo $status[$item->status];?></p>
                                        <?php if ($item->status==1) :?>
                                        <a class="btn mini green" href="<?php echo base_url('tourismreviews/updateStatus/'.$pg_now.'?status=2&id='.$item->id) ?>" onclick="return confirm('确定通过吗')">通过</a>
                                        <a class="btn mini green" href="<?php echo base_url('tourismreviews/updateStatus/'.$pg_now.'?status=3&id='.$item->id) ?>" onclick="return confirm('确定拒绝吗')">拒绝</a>
                                        <?php endif;?>
                                    </td>
                                    <td><?php echo $item->created_at;?></td>
                                    <td width="80">
                                        <a class="btn mini green" href="<?php echo base_url('tourismreviews/edit/'.$item->id) ?>">详情</a>
                                    </td>
                                </tr>
                                <?php endforeach;?>
                            </tbody>
                        </table>
                        <div class="row-fluid">
                            <div class="span6">
                                <div class="dataTables_info">
                                    <span>当前第</span><span style="color: red"><?php echo $pg_now?></span>页 
                                    <span>共</span><span style="color: red"><?php echo $all_rows?></span>条数据
                                    <span>每页显示20条 </span>
                                    <?php echo $pg_list ?>
                                </div>
                            </div>
                        </div>
                        <?php else: ?>
                            <div class="alert"><p>未找到数据。<p></div>
                        <?php endif ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" >
jQuery(function(){
	
	$('.scebery-order-find  button').click(function(){
	   var pg = $(this).parents('.scebery-order-find').find('input[name="pg"]').val();
	   if (pg.length==0) {
	       return false;
	   }
	   window.location.href="<?php echo base_url('tourismreviews/grid')?>"+"/"+pg+"<?php echo isset($url) ? $url :'';?>";
	})

    $('.scebery-order-find').delegate('.agree,.reject','click',function(e){

  	   var id = [];
	   var type = $(this).attr('flag');
	   var pg = $(this).attr('pg');
	   var _this = $(this);
       $('.order-review:checked').each(function(i){
      	   id[i] = $(this).val();
       })
       if (id.length==0) {
   	       return alert('请选择评论序列号');
       }
       $.ajax({
    	   type: 'post',
           async: true,
           dataType: 'json',
           url: hostUrl() + '/tourismreviews/batchSetStatus',
           data: {type:type,pg:pg,id:id},
           beforeSend:function(){
        	   _this.text('操作中').attr("disabled",true);
           },
           success: function (data) {
               if (data.status) {
                   $('.alert-error').hide();
                   window.location.href = data.messages;
               } else {
                   $('.alert-error').show();
                   $('.alert-error .remove_2 p').html(data.messages);
                   var body = (window.opera) ? (document.compatMode == 'CSS1Compat' ? $('html') : $('body')) : $('html,body');
                   body.animate({scrollTop: $('.page-container').offset().top}, 1000);
                   _this.text('请重新操作').attr("disabled",false);
               }
           }
       })
   })
	

	
}) 
</script>
<?php $this->load->view('layout/footer');?>